﻿using System;
using System.Web.Mvc;
using GdNet.Web.Mvc;
using GdNet.WebFramework.Domain.ReferencesData;
using GdNet.WebFramework.Domain.Repositories.ReferencesData;

namespace GdNet.WebFramework.Gui.Controllers
{
    public class HomeController : AbstractController
    {
        private readonly ICatalogRepository _catalogRepository;

        public HomeController(ICatalogRepository catalogRepository)
        {
            _catalogRepository = catalogRepository;
        }

        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";

            // Test data
            _catalogRepository.Save(Catalog.Factory.Create(Guid.NewGuid().ToString(), "Test"));
            var allCatalogs = _catalogRepository.GetAll();
            ViewBag.CatalogsCount = allCatalogs.Count;

            return View();
        }

        public ActionResult About()
        {
            return View();
        }
    }
}
